import { increment, decrement } from "../store/actions/couter";
import { connect } from "react-redux";

function Counter(props) {
    const { count, time, increment, decrement } = props;
    return (
        <>
            <div className='alert alert-info'>
                当前count的值为：{count}
                <br />
                当前time的值为:{time}
            </div>
            <div className='btn-group'>
                <button
                    className='btn btn-primary'
                    onClick={() => increment(1)}
                >
                    增加
                </button>
                <button className='btn btn-danger' onClick={() => decrement(1)}>
                    减少
                </button>
            </div>
        </>
    );
}

const mapState = (state) => {
    return {
        count: state.counter.count,
        time: state.time.time,
    };
};

export default connect(mapState, { increment, decrement })(Counter);
